﻿using System;
using System.Collections.Generic;
using System.Text;
using System.Data;
using System.Data.OleDb;
using System.Data.Common;

namespace Helper
{
    /// <summary>
    /// Helper for Access database.
    /// </summary>
    public class AccessDB : DbHelper
    {
        /// <summary>
        /// Constructor for default.
        /// </summary>
        public AccessDB()
            : base()
        {

        }

        /// <summary>
        /// use specific connection string to initialize database helper.
        /// </summary>
        /// <param name="connectionString"></param>
        public AccessDB(string connectionString)
            : base(connectionString)
        {

        }


        /// <summary>
        /// Constructor for support the transaction.
        /// </summary>
        /// <param name="transaction">current transaction</param>
        public AccessDB(DbTransaction transaction)
            : base(transaction)
        {

        }

        #region override
        /// <summary>
        /// initialize sql connection with specific connection string
        /// </summary>
        protected override void Initialize(string connectionString)
        {
            conn = new OleDbConnection(connectionString);
            cmd = conn.CreateCommand();
        }

        /// <summary>
        /// Get DataAdapter for Access database.
        /// </summary>
        /// <returns>DataAdapter for Access database</returns>        
        protected override DbDataAdapter GetDataAdapter()
        {
            return new OleDbDataAdapter();
        }

        /// <summary>
        /// it is not support by Access database
        /// </summary>
        /// <param name="paramName">parameter name</param>
        public override void AddReturnParameter(string paramName)
        {
            throw new NotSupportedException("Access database is not support return parameter.");
        }

        /// <summary>
        /// it is not support by Access database
        /// </summary>
        /// <param name="paramName"></param>
        public override void AddOutputParameter(string paramName)
        {
            throw new NotSupportedException("Access database is not support output parameter.");
        }

        /// <summary>
        /// it is not support by Access database
        /// </summary>
        /// <param name="paramName"></param>
        /// <param name="paramType"></param>
        public override void AddOutputParameter(string paramName, DbType paramType)
        {
            throw new NotSupportedException("Access database is not support output parameter.");
        }

        /// <summary>
        /// it is not support by Access database
        /// </summary>
        /// <param name="paramName"></param>
        /// <param name="paramType"></param>
        /// <param name="size"></param>
        public override void AddOutputParameter(string paramName, DbType paramType, int size)
        {
            throw new NotSupportedException("Access database is not support output parameter.");
        }

        #endregion
    }
}
